#include "fig_bullet_manager.h"

#include "math/facing.h"

void	FIGBulletManager::RomboShoot6(FIGLifeObj* pShooter, const math::Vec2& Pos)
{

	ShootToDegree(pShooter, Pos, 4);
	ShootToDegree(pShooter, Pos, -4);

	ShootToDegree(pShooter,Pos, 12.5);
	ShootToDegree(pShooter,Pos, -12.5);

	ShootToDegree(pShooter,Pos, 25);	
	ShootToDegree(pShooter,Pos, -25);
}

void	FIGBulletManager::RomboShoot5(FIGLifeObj* pShooter, const math::Vec2& Pos)
{
	ShootToDegree(pShooter, Pos, 0);
	ShootToDegree(pShooter, Pos, 12.5);
	ShootToDegree(pShooter, Pos, -12.5);

	ShootToDegree(pShooter, Pos, 25);	
	ShootToDegree(pShooter, Pos, -25);

}

void	FIGBulletManager::RomboShoot4(FIGLifeObj* pShooter, const math::Vec2& Pos)
{
	ShootToDegree(pShooter, Pos, 5);
	ShootToDegree(pShooter, Pos, 20);
	ShootToDegree(pShooter, Pos, -5);
	ShootToDegree(pShooter, Pos, -20);
}

void		FIGBulletManager::SpawnBulletsShapeTriangle(
														FIGLifeObj* pShooter,
														const math::Vec2& Pos,
														const math::Vec2& TargetDir																
														)
{
	const float Dist = 0.03f;
	const float HalfDist = Dist * 0.4f;
	const float VeticalDist = Dist * 0.9f;
	math::Vec2 HoronzontalDir = TargetDir;
	HoronzontalDir.Rotate(90.0f);
	
	const math::Vec2 VerticalDir = TargetDir;

	// middle line
	Spawn(  
			pShooter,
			Pos - ( HoronzontalDir * HalfDist ) ,
			FIGBullet::STARTPOS_LEFT,
			TargetDir
			);
	Spawn(  
			pShooter,
			Pos + ( HoronzontalDir * HalfDist ) ,
			FIGBullet::STARTPOS_RIGHT,
			TargetDir
			);

	// first line
	Spawn(  
			pShooter,
			Pos + ( VerticalDir * VeticalDist) ,
			FIGBullet::STARTPOS_RIGHT,
			TargetDir
			);

	// last line
	
	const math::Vec2 LastLinePos = Pos - ( VerticalDir * VeticalDist);
	
	Spawn(
			pShooter,
			LastLinePos ,
			FIGBullet::STARTPOS_RIGHT,
			TargetDir
			);
	
	Spawn(  
			pShooter,
			LastLinePos - ( HoronzontalDir * Dist) ,
			FIGBullet::STARTPOS_RIGHT,
			TargetDir
			);

	Spawn(
			pShooter,
			LastLinePos + ( HoronzontalDir * Dist) ,
			FIGBullet::STARTPOS_RIGHT,
			TargetDir
			);
			

}


void		FIGBulletManager::SpawnBulletsShapeCircle(
														FIGLifeObj* pShooter,
														const math::Vec2& Pos,
														const math::Vec2& TargetDir																
														)
{
	const int BulletC = 9;
	const float Radius = 0.03f;
	float Degree = 0;
	math::Vec2 P;

	for(int i = 0; i < BulletC; i++)
	{
		Degree += ( 360.0f / (float)BulletC);
		P = math::Facing::VectorFromAngle(Degree);
		P.y *= GraphicsUtil::W2H;
		Spawn(  
			pShooter,
			Pos + (P * Radius),
			FIGBullet::STARTPOS_LEFT,
			TargetDir
			);
	}

}
